<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/17
 * Time: 15:29
 */

namespace App\Http\Controllers\MiniProgramAdmin;


use App\Http\Traits\VipCardTrait;
use App\Http\Logics\MiniProgramAdmin\VipCardLogic;
use App\Http\Controllers\BaseController;
class VipCardController extends BaseController
{
    use VipCardTrait;

    /**
     * @SWG\Post(
     *     path="/vipCard/create",
     *     tags={"VipCard"},
     *     description="创建VIP卡",
     *     operationId="createVipCard",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="name",
     *         in="query",
     *         description="Vip卡名称",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="denomination",
     *         in="query",
     *         description="VIP卡面额",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="minimum_recharge",
     *         in="query",
     *         description="最低续费",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="summary",
     *         in="query",
     *         description="会员卡描述",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="cover",
     *         in="query",
     *         description="会员卡封面",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function createVipCard()
    {
        $loginSession = $this->loginSession;
        $name = $this->name;
        $denomination = $this->denomination;
        $minimum_recharge = $this->minimum_recharge;
        $summary = $this->summary;
        $cover = $this->cover;
        $data = [
            'loginSession' => $loginSession,
            'name' => $name,
            'denomination' => $denomination,
            'minimum_recharge' => $minimum_recharge,
            'summary' => $summary,
            'cover' => $cover
        ];
        $response = VipCardLogic::createVipCard($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/vipCard/update",
     *     tags={"VipCard"},
     *     description="更新VIP卡",
     *     operationId="updateVipCard",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="id",
     *         in="query",
     *         description="VIP卡ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="name",
     *         in="query",
     *         description="Vip卡名称",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="denomination",
     *         in="query",
     *         description="VIP卡面额",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="minimum_recharge",
     *         in="query",
     *         description="最低续费",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="summary",
     *         in="query",
     *         description="会员卡描述",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="cover",
     *         in="query",
     *         description="会员卡封面",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function updateVipCard()
    {
        $id = $this->id;
        $name = $this->name;
        $denomination = $this->denomination;
        $minimum_recharge = $this->minimum_recharge;
        $summary = $this->summary;
        $cover = $this->cover;
        $data = [
            'id' => $id,
            'name' => $name,
            'denomination' => $denomination,
            'minimum_recharge' => $minimum_recharge,
            'summary' => $summary,
            'cover' => $cover
        ];
        $response = VipCardLogic::updateVipCard($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/vipCard/delete",
     *     tags={"VipCard"},
     *     description="删除VIP卡",
     *     operationId="deleteVipCard",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="vip_card_id",
     *         in="query",
     *         description="VIP卡ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function deleteVipCard()
    {
        $vip_card_id = $this->vip_card_id;
        $data = [
            'vip_card_id' => $vip_card_id
        ];
        $response = VipCardLogic::deleteVipCard($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/vipCard/list",
     *     tags={"VipCard"},
     *     description="获取会员卡列表",
     *     operationId="getVipCardList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="key",
     *         in="query",
     *         description="合作者key",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getVipCardList()
    {
        $key = $this->key;
        $data = [
            'key' => $key
        ];
        $response = VipCardLogic::getVipCardList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/vipCard/detail",
     *     tags={"VipCard"},
     *     description="获取会员卡详情",
     *     operationId="getVipCardDetail",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="vip_card_id",
     *         in="query",
     *         description="会员卡ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getVipCardDetail()
    {
        $vip_card_id = $this->vip_card_id;
        $data = [
            'vip_card_id' => $vip_card_id
        ];
        $response = VipCardLogic::getVipCardDetail($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}